package com.gitee.randomobject.mapper;

import com.gitee.randomobject.domain.SysUser;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper {


    void save(SysUser sysUser);

    List<SysUser> findAll();

    @Select("SELECT * FROM `user` WHERE username = #{username}")
    @Results({
            @Result(id = true,property = "userId",column = "userId"),
            @Result(property = "authorities",column = "id",javaType = List.class,
            many = @Many(select = "com.gitee.randomobject.mapper.RoleMapper.findByUid"))
    })
    SysUser findByName(String username);

}
